package com.platform.web.controller.system;

import java.util.List;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.platform.common.annotation.Log;
import com.platform.common.core.controller.BaseController;
import com.platform.common.core.domain.AjaxResult;
import com.platform.common.enums.BusinessType;
import com.platform.system.domain.ProPublicProducproOrder;
import com.platform.system.service.IProPublicProducproOrderService;
import com.platform.common.utils.poi.ExcelUtil;
import com.platform.common.core.page.TableDataInfo;

/**
 * 公益订单信息Controller
 *
 * @author platform
 * @date 2025-02-23
 */
@Tag(name = "公益订单信息", description = "")
@RestController
@RequestMapping("/system/public_order")
public class ProPublicProducproOrderController extends BaseController {
    @Autowired
    private IProPublicProducproOrderService proPublicProducproOrderService;

    /**
     * 查询公益订单信息列表
     */
    @Operation(summary = "查询公益订单信息列表")
    @PreAuthorize("@ss.hasPermi('system:public_order:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProPublicProducproOrder proPublicProducproOrder) {
        startPage();
        List<ProPublicProducproOrder> list = proPublicProducproOrderService.selectProPublicProducproOrderList(proPublicProducproOrder);
        return getDataTable(list);
    }

    /**
     * 查询公益订单信息列表
     */
    @Operation(summary = "查询公益订单信息列表")
    @GetMapping("/listAll")
    public TableDataInfo listAll(ProPublicProducproOrder proPublicProducproOrder) {
        startPage();
        proPublicProducproOrder.setUserId(getUserId());
        List<ProPublicProducproOrder> list = proPublicProducproOrderService.selectProPublicProducproOrderListAll(proPublicProducproOrder);
        return getDataTable(list);
    }

    /**
     * 导出公益订单信息列表
     */
    @Operation(summary = "导出公益订单信息列表")
    @PreAuthorize("@ss.hasPermi('system:public_order:export')")
    @Log(title = "公益订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProPublicProducproOrder proPublicProducproOrder) {
        List<ProPublicProducproOrder> list = proPublicProducproOrderService.selectProPublicProducproOrderList(proPublicProducproOrder);
        ExcelUtil<ProPublicProducproOrder> util = new ExcelUtil<ProPublicProducproOrder>(ProPublicProducproOrder.class);
        util.exportExcel(response, list, "公益订单信息数据");
    }

    /**
     * 获取公益订单信息详细信息
     */
    @Operation(summary = "获取公益订单信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:public_order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(proPublicProducproOrderService.selectProPublicProducproOrderById(id));
    }

    /**
     * 新增公益订单信息
     */
    @Operation(summary = "新增公益订单信息")
    @PreAuthorize("@ss.hasPermi('system:public_order:add')")
    @Log(title = "公益订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProPublicProducproOrder proPublicProducproOrder) {
        proPublicProducproOrder.setUserId(getUserId());
        proPublicProducproOrder.setCreateBy(getUsername());
        return toAjax(proPublicProducproOrderService.insertProPublicProducproOrder(proPublicProducproOrder));
    }

    /**
     * 修改公益订单信息
     */
    @Operation(summary = "修改公益订单信息")
    @PreAuthorize("@ss.hasPermi('system:public_order:edit')")
    @Log(title = "公益订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProPublicProducproOrder proPublicProducproOrder) {
        proPublicProducproOrder.setUpdateBy(getUsername());
        return toAjax(proPublicProducproOrderService.updateProPublicProducproOrder(proPublicProducproOrder));
    }

    /**
     * 删除公益订单信息
     */
    @Operation(summary = "删除公益订单信息")
    @PreAuthorize("@ss.hasPermi('system:public_order:remove')")
    @Log(title = "公益订单信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(proPublicProducproOrderService.deleteProPublicProducproOrderByIds(ids));
    }
}
